﻿using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.Practices.ServiceLocation;
using NCommon.Data;

namespace MyPetShop.Domain
{
	/// <summary>
	/// Description of Product.
	/// </summary>
	public class Product
	{
		public virtual int ProductId { get;protected set;}
		public virtual string Name {get;set;}
		public virtual string Description {get;set;}
		public virtual bool IsDelete{get;protected set;}
		public virtual Category Category {get;set;}
	
		public Product()
		{
		}

		public virtual void Delete()
		{
			this.IsDelete = true;
			
			var repository = ServiceLocator.Current.GetInstance<IRepository<Item>>();
			IList<Item> items = repository.Where(s=>s.Product == this).ToList();
			
			foreach(var item in items)
			{
				item.Delete();
			}
		}
	}
}
